<?php
require_once('App-Top.php');
//// require_once('Cookie-Handler.php'); //// Only Activate in UNProtected Area
require_once('Authorizer.php'); //// Only Activate in Protected Area
require_once('FEFunctions.php');
//// RSVP.php
//// This is the RSVP page for the WOG site.
//// Set Page Title
$page_title = 'RSVP -  Whiff Of Grape';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title><?php echo $page_title; ?></title>
        <style type="text/css" media="screen">@import url(style.css);</style>
    </head>

    <body>
        <div id="bigWrapper">

            <div id="wrapper">

                <div id="header">
                </div>

                <div id="sidebar">

                <?php
                require_once('MenuLeft.php');
                ?>

                </div>

                <!-- End of Header & Start Content -->

                <div id="body">

                    <div id="entryTitlePage"><?php echo $page_title; ?></div>


                    <?php
                    require_once(MYSQL);
                    require_once(STATEM_MYSQL);
                    require_once('FEFunctions.php');
                    require_once('ShowEventsFunctions.php');
                    
                    //// Check for the existence of that email address
                    $qEventsUpcomingBlocked = sprintf($Q_ALL_NONE_Events_StatusUorB);
                    $rEventsUpcomingBlocked = mysqli_query($dbc, $qEventsUpcomingBlocked) or trigger_error("Query: $qEventsUpcomingBlocked\n<br />MySQL Error: " . mysqli_error($dbc));

                    $numRowsEventsUB = mysqli_num_rows($rEventsUpcomingBlocked);

                    if ($numRowsEventsUB >= 1)
                    {
                        // Contains the information of each Event that is set as Upcoming/Blocked
                        $arrayEventsUB;
                        $indexRows = 0;
                        while ($indexRows < $numRowsEventsUB)
                        {
                                $arrayEventsUB[] = mysqli_fetch_array ($rEventsUpcomingBlocked, MYSQLI_ASSOC);
                                $indexRows++;
                        }

                        // Contains the information of Member Attendance vs Event Upcoming/Blocked
                        $indexRows = 0;
                        foreach ($arrayEventsUB as $rowEventsUB)
                        {

                            $qAttendanceEventMember = sprintf($Q_ALL_Eventid_EventMemberAttend, $rowEventsUB['EventId'], $_SESSION['SESS_USER_EMAIL_FE_ID']);
                            $rAttendanceEventMember = mysqli_query($dbc, $qAttendanceEventMember) or trigger_error("Query: $qAttendanceEventMember\n<br />MySQL Error: " . mysqli_error($dbc));

                            if (mysqli_num_rows ($rAttendanceEventMember) == 1)
                            {
                                // The member has submitted some information
                                showMemberAttendanceRSVPForm($rowEventsUB, mysqli_fetch_array ($rAttendanceEventMember, MYSQLI_ASSOC));
                            }
                            else
                            {
                                // The member has not submitted any information
                                showMemberAttendanceRSVPForm($rowEventsUB, NULL);
                            }

                            mysqli_free_result($rAttendanceEventMember);

                            // Display the event formatted
                            echo '<br />';

                            showIndexEvents($rowEventsUB, NULL, 'D' );

                            $indexRows++;
                            if ($numRowsEventsUB > $indexRows)
                            {
                                echo '<div class="timingEventsLineInner"></div>';
                            }
                        }
                    }
                    else
                    {
                        //// Events set as Upcoming/Blocked.
                        echo '<p class="entrybodybold">There are currently no Events to RSVP. Please visit us later.</p>';
                    }
                    
                    mysqli_free_result($rEventsUpcomingBlocked);
                    mysqli_close($dbc);

                    ?>


                </div> <!-- Closes body -->
                <!-- End of Content & Start Footer -->

                <div id="footer">

                    <?php
                    //// Includer Footer
                    include ('footer.php');
                    ?>

                </div>

                </div> <!-- Closes Wrapper -->
            </div> <!-- Closes bigWrapper -->
        </body>
    </html>
<?php
require_once('App-End.php');
?>

<!-- Designed & Developed By Jose Trujillo (2011) -->